<%@page import="com.hhit.collaborative_learning.utils.Utils"%>
<%@page import="com.hhit.collaborative_learning.entity.BlogExpert"%>
<%@page
	import="com.hhit.collaborative_learning.dao.impl.PublicDaoImplMySql"%>
<%@page import="com.hhit.collaborative_learning.entity.User"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page isELIgnored="false"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	String userId = request.getParameter("userId");
	PublicDaoImplMySql dao = new PublicDaoImplMySql();
	BlogExpert expert = dao.getExpertApplyResult(Integer
			.parseInt(userId));
	request.setAttribute("expert", expert);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<!--new top-->
<link rel="stylesheet" href="<%=basePath%>css/index.css">
<!--new top-->

<link rel="Stylesheet" type="text/css" href="<%=basePath%>css/home.css" />
<script src="<%=basePath%>js/jquery.js" type="text/javascript"></script>
<script src="<%=basePath%>js/home.js" type="text/javascript"></script>
<script src="<%=basePath%>js/plugins.js" type="text/javascript"></script>
<script type="text/javascript">
var showConfirm = true;
if('<%=expert.applyState%>'!='1'){
showConfirm=false;
}
window.onbeforeunload = function () {
        if (showConfirm) {
            return "你还没有提交审核";
        }
};
</script>
</head>
<body>

	<div role="banner" class="blog-nav"></div>
	<div id="wrap">
		<div class="main_con">
			<style type="text/css">
th {
	text-align: right;
	color: #777;
}

/* input { */
/* 	width: 220px; */
/* } */

#btnsub {
	width: 80px;
}

.err {
	padding-left: 10px;
	color: Red;
}
</style>
			<!-- //nav -->
			<script src="<%=basePath%>js/csdn.check.js" type="text/javascript"></script>
			<div class="main_con">
				<div class="bor_box rule">
					<h2>审核博客专家申请</h2>
					<table border="1" cellspacing="0" cellpadding="0">
						<tr>
							<th colspan="2"
								style="text-align: left;PADDING-BOTTOM: 4px; PADDING-LEFT: 10px; PADDING-RIGHT: 4px; PADDING-TOP: 4px">
									申请人:<a href="<%=basePath%>learning/personal.jsp?userId=<%=userId%>" target="_blank">${requestScope.expert.realName}</a>
								</th>
						</tr>
						<tr>
							<th
								style="text-align: left;PADDING-BOTTOM: 4px; PADDING-LEFT: 10px; PADDING-RIGHT: 4px; PADDING-TOP: 4px">1.原创IT类文章总数超过20篇，并且最近一个月内发布了新的原创IT类文章</th>
							<td style="text-align: left;PADDING-BOTTOM: 4px; PADDING-LEFT: 10px; PADDING-RIGHT: 4px; PADDING-TOP: 4px"><c:choose>
									<c:when test="${requestScope.expert.conditionOne eq 0}">
										审核不通过
									</c:when>
									<c:when test="${requestScope.expert.conditionOne eq 1}">
										审核通过
									</c:when>
									<c:when test="${requestScope.expert.conditionOne eq 2}">
										<a href="#" onclick="examine(this,1,'${requestScope.expert.time}');return false;">自动审核</a>
									</c:when>
								</c:choose><input id="type1" type="hidden" value="${requestScope.expert.conditionOne }"/></td>
						</tr>
						<tr>
							<th
								style="text-align: left;PADDING-BOTTOM: 4px; PADDING-LEFT: 10px; PADDING-RIGHT: 4px; PADDING-TOP: 4px">2.博客文章总的浏览量超过5万次以上</th>
							<td style="text-align: left;PADDING-BOTTOM: 4px; PADDING-LEFT: 10px; PADDING-RIGHT: 4px; PADDING-TOP: 4px"><c:choose>
									<c:when test="${requestScope.expert.conditionTwo eq 0}">
										审核不通过
									</c:when>
									<c:when test="${requestScope.expert.conditionTwo eq 1}">
										审核通过
									</c:when>
									<c:when test="${requestScope.expert.conditionTwo eq 2}">
										<a href="#" onclick="examine(this,2,'${requestScope.expert.time}');return false;">自动审核</a>
									</c:when>
								</c:choose><input id="type2" type="hidden" value="${requestScope.expert.conditionTwo }"/></td>
						</tr>
						<tr>
							<th
								style="text-align: left;PADDING-BOTTOM: 4px; PADDING-LEFT: 10px; PADDING-RIGHT: 4px; PADDING-TOP: 4px">3.文章内容的质量很高&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="<%=basePath%>learning/personal.jsp?userId=<%=userId%>" target="_blank">查看</a></th>
							<td style="text-align: left;PADDING-BOTTOM: 4px; PADDING-LEFT: 10px; PADDING-RIGHT: 4px; PADDING-TOP: 4px"><c:choose>
									<c:when test="${requestScope.expert.conditionThree eq 0}">
										审核不通过
									</c:when>
									<c:when test="${requestScope.expert.conditionThree eq 1}">
										审核通过
									</c:when>
									<c:when test="${requestScope.expert.conditionThree eq 2}">
										<input type="radio" name="examine" value="0"/>审核通过&nbsp;&nbsp;&nbsp;&nbsp;<input
											type="radio" name="examine" value="1"/>审核不通过
									</c:when>
								</c:choose><input id="type3" type="hidden" value="${requestScope.expert.conditionThree }"/></td>
						</tr>
						<tr>
						
							<td colspan="2" align="center"
								style="PADDING-BOTTOM: 4px; PADDING-LEFT: 4px; PADDING-RIGHT: 4px; PADDING-TOP: 4px"><input
								id="button" class="btn" type="button" value="提交审核" <c:if test="${requestScope.expert.applyState ne 1}">disabled</c:if>/> <span
								class="err" id="Sp_err"></span></td>
						</tr>
					</table>
				</div>
			</div>
			<script language="javascript" type="text/javascript">
				function examine(e,type,time){
					$.post("<%=basePath%>ExamineApplyServlet",{userId:<%=userId%>,type:type,time:time},function(data,status){
						if(data=='true'){
							$("#type"+type).val("0");
							$(e).text("审核通过");
						}else{
							$("#type"+type).val("1");
							$(e).text("审核不通过");
						}
						$(e).attr("onclick","return false;");
					});
				}
				function submitExamine(c1,c2,c3,state){
					$.post("<%=basePath%>SubmitExamineServlet",{con1:c1,con2:c2,con3:c3,userId:<%=userId%>,state:state},function(data,status){
						if(data=='true'&&state!=1){
							alert("提交成功!");
							$("#button").attr("disabled","true");
						}else if(data=='true'&&state==1){
							alert("提交成功!");
						}
					});
				}
				$(function () {
						$("input[name='examine']").change(function(){
							var choose= $("input[name='examine']:checked").val();
							$("#type3").val(choose);
						});
						
						$("#button").click(function(){
							var type1=$("#type1").val();
							var type2=$("#type2").val();
							var type3=$("#type3").val();
							if(type1=='2'||type2=='2'||type3=='2'){
								if(confirm("你还没有审核完成，是否继续提交")){
									submitExamine(type1,type2,type3,1);
								}
							}else if(type1=='0'||type2=='0'||type3=='0'){
								submitExamine(type1,type2,type3,2);
								showConfirm=false;
							}else{
								submitExamine(type1,type2,type3,0);
								showConfirm=false;
							}
						});
				});
			</script>

		</div>
	</div>
	<link href="<%=basePath%>css/ask_float_block.css" type="text/css"
		rel="stylesheet" />
	<script type='text/javascript'>
		(function() {
			$(function() {
				var back_top_value = Math
						.ceil(document.documentElement.clientHeight * 0.65);
				var float_ask_img = "<div data-mod='popu_64' class='tracking-ad' chg-blk='0' ><a id='com-d-top-a'  style='top:"+back_top_value+"px' title='返回顶部' onclick='' ></a> </div>";
				$("body").append(float_ask_img);

				var d_top = $('#com-d-top-a');

				$(document)
						.scroll(
								function() {
									var scrTop = (document.body.scrollTop || document.documentElement.scrollTop);
									if (scrTop > 500) {
										d_top.show();
									} else {
										d_top.hide();
									}

								})
				$('#com-d-top-a').click(function() {
					scrollTo(0, 0);
					this.blur();
					return false;
				});
			});
		})();
	</script>
</body>
</html>
